import java.util.*;

public class SubstractionQuizLoop {
    public static void main(String[] args) {
        final int NUMBER_OF_QUESTIONS = 5;
        int correctCount = 0;
        int count = 0;
        long startTime = System.currentTimeMillis();
        String output = "";
        Scanner scanner = new Scanner(System.in);
        
        while(count < NUMBER_OF_QUESTIONS) {
            
            int number1 = (int)(Math.random() * 10);
            int number2 = (int)(Math.random() * 10);
            
            if(number1 < number2) {
                int temp = number1;
                number1 = number2;
                number2 = temp;
            }
            
            System.out.println("Cik ir " + number1
                    + " - " + number2 + " ?");
            int answer = scanner.nextInt();
            
            if(number1 - number2 == answer) {
                System.out.println("Atbilde pareiza!");
                correctCount++;
            }
            else
                System.out.println("Atbilde nepareiza!\n"
                        + number1 + " - " + number2 + " = " + answer);
            count++;
            
            output += "\n" + number1 + " - " + number2 + " = "
                    + answer + ((number1 - number2 == answer) ? " Pareizi!" : " Nepareizi!");
        }
        
        long endTime = System.currentTimeMillis();
        long testTime = endTime - startTime;
        
        System.out.println("Pareizi atbildēji " + correctCount
                + "\nTesta laiks ilga " + testTime / 1000 + " sekundes\n" + output);
    }
}
